package net.anzhuo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.common.enums.ResultEnum;
import net.anzhuo.common.utils.ExceptionUtil;
import net.anzhuo.dao.GsShangbiaoMapper;
import net.anzhuo.entity.GsShangbiao;
import net.anzhuo.service.GsShangbiaoService;

@Service
public class GsShangbiaoServiceImpl implements GsShangbiaoService {

	@Autowired
	private GsShangbiaoMapper gsShangbiaoMapper;

	@Override
	public PaginationVO<GsShangbiao> getListWithPage(GsShangbiao gsShangbiao) {
		PaginationVO<GsShangbiao> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsShangbiaoMapper.getListWithPage(gsShangbiao));
		paginationVO.setTotalCount(gsShangbiaoMapper.getCount(gsShangbiao));
		paginationVO.setTotalPage((gsShangbiaoMapper.getCount(gsShangbiao) + gsShangbiao.getPageSize() -1)  / gsShangbiao.getPageSize()+1);
		paginationVO.setPageNo(gsShangbiao.getPageNo());
		return paginationVO;
	}

	@Override
	public GsShangbiao getById(Long id) {
		return gsShangbiaoMapper.getById(id);
	}

	@Override
	public List<GsShangbiao> getList() {
		return gsShangbiaoMapper.getList();
	}

	@Override
	public List<GsShangbiao> getList(GsShangbiao gsShangbiao) {
		return gsShangbiaoMapper.getListByQuery(gsShangbiao);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsShangbiao gsShangbiao) {
		gsShangbiaoMapper.update(gsShangbiao);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsShangbiao gsShangbiao) {
		gsShangbiaoMapper.save(gsShangbiao);
	}
	
	@Override
	public List<GsShangbiao> getByMd5(String md5) {
		return gsShangbiaoMapper.getByMd5(md5);
	}
	
	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsShangbiao gsShangbiao) {
		gsShangbiaoMapper.delete(gsShangbiao);
	}
}
